<template>
  <div class="singer" v-loading="!singers.length">
    <index-list :data="singers" @select="onSelect"></index-list>
    <router-view v-slot="{ Component }">
      <transition name="slide" appear>
        <component :is="Component" :data="selectSinger" />
      </transition>
    </router-view>
  </div>
</template>

<script>
import { getSingerList } from '@/service/singer.js';
import IndexList from '@/components/base/index-list/index-list';
import storage from 'good-storage';
import { SINGER_KEY } from '@/assets/js/constant';
export default {
  name: 'singer',
  components: {
    IndexList
  },
  data() {
    return {
      singers: [],
      selectSinger: null,
      rout: ''
    };
  },
  async created() {
    const result = await getSingerList();
    this.singers = result.singers;
  },
  methods: {
    onSelect(singer) {
      this.selectSinger = singer;
      this.cacheSinger(singer);
      this.$router.push({
        path: `/singer/${singer.mid}`
      });
    },
    cacheSinger(singer) {
      storage.session.set(SINGER_KEY, singer);
    }
  }
};
</script>

<style lang="scss" scoped>
.singer {
  position: fixed;
  width: 100%;
  top: 88px;
  bottom: 0;
}
</style>
